package old_go_learn

import (
	"encoding/json"
	"fmt"
)

type IT struct {
	Company  string   `json:"company"`
	Subjects []string `json:"-"`
	IsOk     bool     `json:",string"`
	Price    float64  `json:",string"`
}

func main() {
	jsonBuf := `{"company":"ky","isOk":true,"price":55.4,"sub":["go","c++"]}`

	m := make(map[string]interface{}, 4)
	err := json.Unmarshal([]byte(jsonBuf), &m)
	if err != nil {
		fmt.Println("tmp = ", err)
		return
	}
	fmt.Printf("m = %+v\n",m)

	//类型断言
	for key, value := range m {
		//fmt.Printf("%v =========> %v\n",key,value)

		switch data := value.(type) {

		case string:
			fmt.Printf("map[%s]的类型为string, value =  %v\n", key, data)
		case bool:
			fmt.Printf("map[%s]的类型为bool, value = %v \n", key, data)
		case float64:
			fmt.Printf("map[%s]的类型为float64,value = %v\n", key, data)
		case float32:
			fmt.Printf("map[%s]的类型为float32,value = %v\n", key, data)
		case []interface{}:
			fmt.Printf("map[%s]的类型为[]interface{},value = %v\n", key, data)

		}
	}

}
